{extend name="public:base"}
{block name='css'}
{/block}

{block name='body'}
<div class="view view-main white-navbar white-page white-toolbar">
    <div data-name="home" class="page js-page" data-handle="2">

        <div class="navbar">
            <div class="navbar-inner">
                <div class="left"><a href="{$my_prev_url|default='/'}" class="external"><i class="iconfont icon-fanhui"></i></a></div>
                <div class="center"><span>搜索</span></div>
                <div class="right"></div>
            </div>
        </div>

        <div class="page-content infinite-scroll-content">

            <div class="serach">
                <form name="form" action="" id="form" method="post" onsubmit="return false;" >
                    <div class="m">
                        <div class="ico"></div>
                        <div class="key"><input type="text" name="keywords" value="{:input('keywords')}" placeholder="请输入关键字搜索" /></div>
                    </div>
                    <div class="sub"><input type="submit" value="搜索" /></div>
                </form>
            </div>

            <div class="bakcground-10"></div>

            <div class="home-goods-ul" data-cate_id="{:input('cate_id')}">
            </div>

            {include file='public:loading' /}
        </div>

        {include file='public:tab' /}
    </div>
</div>
{/block}

{block name="js"}
<script type="text/javascript">
    $(function(){
        searchGoods();
    });
    function searchGoods() {
        $('.home-goods-ul').html('');
        $('.no-more').hide();
        $('.no-data').hide();
        getGoodsList('', 2, $('input[name=keywords]').val());
    }

    //触发无限滚动
    $$('.infinite-scroll-content').on('infinite', function () {
        getGoodsList('', 2, $('input[name=keywords]').val());
    });

    $().ready(function () {
        $("#form").validate({
            rules: {
                keywords: "required"
            },
            messages: {
                keywords: '请输入关键字'
            },
            showErrors: function (errorMap, errorList) {
                $.each(errorList, function (i, v) {
                    messageToast( v.message );
                    return false;
                });
            },
            onfocusout: false,
            onsubmit : true ,
            onkeyup : false ,
            onclick : false ,
            focusInvalid:false,
            submitHandler:function(){
                searchGoods();
            }
        });
    });
</script>
{/block}